package com.hzit.sb2.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hzit.sb2.bean.Emp;
import com.hzit.sb2.mapper.EmpMapper;
import com.hzit.sb2.service.IEmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class EmpServiceImpl implements IEmpService {
    @Autowired
    EmpMapper empMapper;

    @Override
    public PageInfo<Emp> findAll(Integer deptno, String ename, Integer page, Integer pageSize) {
        PageHelper.startPage(page, pageSize);
        PageInfo<Emp> pageInfo = new PageInfo<>(empMapper.findAll(deptno, ename));
        return pageInfo;
    }

    @Override
    public int insert(Emp emp) {
        return empMapper.insert(emp);
    }

    @Override
    public int deleteByPrimaryKey(Integer empno) {
        return empMapper.deleteByPrimaryKey(empno);
    }

    @Override
    public Emp selectByPrimaryKey(Integer empno) {
        return empMapper.selectByPrimaryKey(empno);
    }

    @Override
    public int updateEmp(Emp emp) {
        return empMapper.update(emp);
    }
}
